
import axios from 'axios';
import router from '@/router';


const a= axios.create({})

import s from '@/stores/userStore.js'

// a.interceptors.request.use(config =>{
//     return config
// })


a.interceptors.response.use(
    function(response){
               
        switch(response.data.state){
            case 200:return response;
            case 250:
                alert(response.data.msg)
                sessionStorage.removeItem('mc')
                s().clearUser()
                router.push('/reg')
            default:alert(response.data.msg)
        }
    },
    function(error){
        switch(error.response.status){
            case 404:alert("服务器连接不上");break;
            case 401:alert("服务器要求认证");break;
        }
        return Promise.reject(error);
    }

)


export default a;